﻿// See https://aka.ms/new-console-template for more information
using System.Diagnostics;
//计算代码运行的时间
Stopwatch stopWatch = new Stopwatch();
//输入数字
Console.WriteLine("请输入一个很大的数字");
int number = int.Parse(Console.ReadLine());
//开始计时
stopWatch.Start();
int prime = 0;
//判断质数
for(int i = number; i >1; i--)
{
    for(int j = 2; j <=i;j++)
    {
        if (i % j == 0)
            if (j == i)
                prime = i;
            else 
                break;   
    }
    if (prime == i)
        break;
}
Console.WriteLine($"{number}以内最大的质数是{prime}");
//停止计时
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
double time = ts.TotalMilliseconds;
Console.WriteLine($"运行时间为{time}毫秒");
